package entity;

import org.hibernate.annotations.*;
import org.hibernate.annotations.Cache;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

/**
 * Created by xuweijie on 2017/4/20.
 * 收货地址类实体
 */
@Entity
@Table(name = "cro_address")
@DynamicInsert(true)
//@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class CroAddress implements Serializable {

    private String id;
    private CroCustomer croCustomer;
    private String consignee;
    private SysCountry country;
    private SysProvience provience;
    private SysCitys city;
    private String address;
    private String postcode;
    private String phone;
    private Date createtime;
    private Date updatetime;
    private String del_flag;


    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @ManyToOne(cascade ={CascadeType.REFRESH},fetch =FetchType.EAGER)
    @JoinColumn(name ="costemId",referencedColumnName = "id")
    public CroCustomer getCroCustomer() {
        return croCustomer;
    }

    public void setCroCustomer(CroCustomer croCustomer) {
        this.croCustomer = croCustomer;
    }

    public String getConsignee() {
        return consignee;
    }

    public void setConsignee(String consignee) {
        this.consignee = consignee;
    }

    @ManyToOne(cascade ={CascadeType.REFRESH},fetch =FetchType.EAGER)
    @JoinColumn(name ="country",referencedColumnName = "id")
    public SysCountry getCountry() {
        return country;
    }

    public void setCountry(SysCountry country) {
        this.country = country;
    }

    @ManyToOne(cascade ={CascadeType.REFRESH},fetch =FetchType.EAGER)
    @JoinColumn(name ="provience",referencedColumnName = "id")
    public SysProvience getProvience() {
        return provience;
    }

    public void setProvience(SysProvience provience) {
        this.provience = provience;
    }

    @ManyToOne(cascade ={CascadeType.REFRESH},fetch =FetchType.EAGER)
    @JoinColumn(name ="city",referencedColumnName = "id")
    public SysCitys getCity() {
        return city;
    }

    public void setCity(SysCitys city) {
        this.city = city;
    }


    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPostcode() {
        return postcode;
    }

    public void setPostcode(String postcode) {
        this.postcode = postcode;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @CreationTimestamp
    public Date getCreatetime() {
        return createtime;
    }

    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }

    @UpdateTimestamp
    public Date getUpdatetime() {
        return updatetime;
    }

    public void setUpdatetime(Date updatetime) {
        this.updatetime = updatetime;
    }

    @Column(columnDefinition ="varchar(1) default 0")
    public String getDel_flag() {
        return del_flag;
    }

    public void setDel_flag(String del_flag) {
        this.del_flag = del_flag;
    }
}
